/**
 * s型旋转数组
 * @param arr 
 */
const sReverse = (arr: number[][]): number[] => {
    const len = arr.length;

    const ans: number[] = []


    let index = 0;
    for (let i = 0; i < len; i++) {
        if (i % 2 === 0) {  
            for (let j = 0; j < arr[i].length; j++) {
                ans[index++] = arr[i][j]
            }
        } else {
            for (let j = arr[i].length - 1; j >= 0; j--) {
                ans[index++] = arr[i][j]
            }
        }
    }

    return ans
} 

console.log(sReverse([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]))